<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/3/22
  Time: 16:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en">
<meta charset="utf-8">
<title>资讯</title>
<link rel="shortcut icon" href="favicon.ico">
<link href="../static/css/bootstrap.min.css" rel="stylesheet">
<link href="../static/css/font-awesome.css" rel="stylesheet">

<!-- jqgrid-->
<link href="../static/css/plugins/jqgrid/ui.jqgrid.css" rel="stylesheet">

<link href="../static/css/animate.css" rel="stylesheet">
<link href="../static/css/style.css" rel="stylesheet">

<style>
    #tab{
        width: 600px;
        margin-top: 20px;
    }
    td{
        text-align: center;!important;
    }
    th{
        text-align: center;!important;
    }
    p input{
        width: 200px !important;
        display: inline-block !important;
    }
    select {
        width: 120px;
        height: 37px;
        text-align: center;
        text-align-last: center;
    }
</style>

</head>

<body>


<div style="width: 100%">
    <h2 style="margin-left: 13px;display: inline-block">资讯列表</h2>
</div>
<div class="jqGrid_wrapper">
    <table id="table_list_1"></table>
    <%--    jqgrid增 改 删 查 刷新--%>
    <div id="pager_list_1"></div>
</div>
<!-- 全局js -->
<script src="../static/js/jquery.min.js"></script>
<script src="../static/js/bootstrap.min.js"></script>

<!-- Peity -->
<script src="../static/js/plugins/peity/jquery.peity.min.js"></script>

<!-- jqGrid -->
<script src="../static/js/plugins/jqgrid/i18n/grid.locale-cn.js"></script>
<script src="../static/js/plugins/jqgrid/jquery.jqGrid.min.js"></script>

<!-- 自定义js -->
<script src="../static/js/content.js"></script>
<script>
$(document).ready(function () {
    $.jgrid.defaults.styleUI = 'Bootstrap';
    let users = "";
    //请求后台数据
    $.ajax({
        url: 'news?opr=listAll',
        method:'POST',
        data:'',
        datatype:'JSON',
        //让异步变成同步      代表
        async:false,
        success:function (d){
            users=$.parseJSON(d);
        }
    })
    $("#table_list_1").jqGrid({
        data: users,
        datatype: "local",
        height: 460,
        autowidth: true,
        shrinkToFit: true,
        rowNum: 10,
        rowList: [10,20,30],

        colNames: ['文章标题', '创建时间'],
        colModel:[

            {
                name: 'title',
                index: 'title',
                width: 90,
            },

            {
                name: 'createTime',
                index: 'createTime',
                width: 90,
            },
        ],
        //jqgrid增 改 删 查 刷新
        pager: "#pager_list_1",
        //记录信息 ！！
        viewrecords: true,

        caption: "",
        add: true,
        edit: true,
        addtext: '增加',
        edittext: '修改',
        hidegrid: false
    });
    $("#add_table_list_1").remove();
    // $("#pager_list_1_left").html("<a>点击详情</a>");
    /* show();*/



    // Add selection 默认选中第1行
    $("#table_list_1").setSelection(1, true);


    // Setup buttons  jqgrid增 改 删 查 刷新
    $("#table_list_1").jqGrid('navGrid', '#pager_list_1', {
        edit: true,
        add: true,
        del: true,
        search: true
    }, {
        height: 20,
        reloadAfterSubmit: true
    });

    $("#first_pager_list_1,#prev_pager_list_1,#next_pager_list_1,#last_pager_list_1").click(function(){
        //show();
    })
});
</script>
</body>
</html>
